﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Hutech.Authentication.Library.Web.Framework;
using Resources;
using Hutech.Authentication.Library.Business.WebHelpers;
using Hutech.CRM.Web;

namespace Hutech.CRM.Web.Admin
{
    public partial class AdminMenu : hutechBasePage
    {
        private bool isAuthorized = false;

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadSettings();
            if (!isAuthorized)
            {
                WebUtils.SetupRedirect(this, SiteRoot + "/AccessDenied.aspx");
                return;
            }

            SecurityHelper.DisableBrowserCache();

            PopulateLabels();
            //PopulateControls();
        }
        #region Load All data
        private void PopulateLabels()
        {
            Title = Resource.AdminMenuHeading;



            liRoleAdmin.Visible = WebUser.IsAdmin;
            lnkRoleAdmin.Text = Resource.AdminMenuRoleAdminLink;
            lnkRoleAdmin.NavigateUrl = SiteRoot + "/Admin/RoleManager.aspx";

            //liFeatureAdmin.Visible = WebUser.IsAdmin;
            //lnkFeatureAdmin.Text = Resource.AdminMenuFeatureModulesLink;
            //lnkFeatureAdmin.NavigateUrl = SiteRoot + "/Admin/ModuleManager.aspx";

            liMemberList.Visible = IsAdmin;
            lnkMemberList.Text = Resource.MemberListLink;
            lnkMemberList.NavigateUrl = SiteRoot + "/Admin/MemberList.aspx";

            liPermissions.Visible = IsAdmin;
            lnkPermissionAdmin.Text = Resource.SiteSettingsPermissionsTab;
            lnkPermissionAdmin.NavigateUrl = SiteRoot + "/Admin/PermissionManager.aspx";

            liPermissions.Visible = IsAdmin;
            lnkAddUser.Text = Resource.MemberListAddUserLabel;
            lnkAddUser.NavigateUrl = SiteRoot + "/Secure/Register.aspx";
        }

        private void LoadSettings()
        {
            isAuthorized = true; //Tao lao bi' dao
        }
        #endregion
    }
}
